/**
 * 
 */
package gui.effects;

import java.awt.Color;
import java.util.Arrays;

import javax.swing.JComponent;

/**
 * Class to change a number of JComponents Foreground color enmass.
 * 
 * @author Joshua Lockerman
 */
public class ForegroundGlow {
    
    private final JComponent[] components;
    private final Color[] originalColors;
    private final Color glowColor;
    
    public ForegroundGlow(Color glowColor, JComponent... components)
    {
        this.glowColor = glowColor;
        this.components = Arrays.copyOf(components, components.length);
        originalColors = new Color[this.components.length];
        for(int i = 0; i < this.components.length; i++) {
            originalColors[i] = this.components[i].getForeground();
        }
    }
    
    public void glow()
    {
        for(int i = 0; i < this.components.length; i++) {
            this.components[i].setForeground(glowColor);
        }
    }
    
    public void unglow()
    {
        for(int i = 0; i < this.components.length; i++) {
            this.components[i].setForeground(originalColors[i]);
        }
    }
}
